package editor.cn;

//You are given a string representing an attendance record for a student. The re
//cord only contains the following three characters:
//
// 
// 
// 'A' : Absent. 
// 'L' : Late. 
// 'P' : Present. 
// 
// 
//
// 
//A student could be rewarded if his attendance record doesn't contain more than
// one 'A' (absent) or more than two continuous 'L' (late). 
//
// You need to return whether the student could be rewarded according to his att
//endance record. 
//
// Example 1: 
// 
//Input: "PPALLP"
//Output: True
// 
// 
//
// Example 2: 
// 
//Input: "PPALLL"
//Output: False
// 
// 
//
//
// Related Topics 字符串 
// 👍 61 👎 0

public class StudentAttendanceRecordI{
    public static void main(String[] args) {
        Solution solution = new StudentAttendanceRecordI().new Solution();
        System.out.println(solution.checkRecord("PPALLL"));
    }

//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean checkRecord(String s) {
        if (s.contains("LLL")) {
            return false;
        }
        char[] chars = s.toCharArray();
        int countA = 0;
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] == 'A') {
                countA++;
            }
            if (countA == 2) {
                return false;
            }
        }
        return true;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}